package com.nativetalk.service.feedback.insert;

import com.nativetalk.base.RetInfo;
import com.nativetalk.bean.feedback.TdNtFeedbackInsert;
import com.nativetalk.common.ValidationMessages;
import com.nativetalk.dao.TdNtFeedbackDao;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by lizhun on 15/12/28.
 */
@Service
public class FeedbackInsertServiceImpl implements FeedbackInsertService{
    private static Logger logger = Logger.getLogger(FeedbackInsertServiceImpl.class);
    @Resource
    private TdNtFeedbackDao tdNtFeedbackDao;
    @Override
    public RetInfo addFeedback(TdNtFeedbackInsert tdNtFeedbackInsert) {
        String logInfo = this.getClass().getName() + ":addFeedback:";
        logger.info("======" + logInfo + "begin======");
        RetInfo retInfo = new RetInfo();
        try {
             tdNtFeedbackDao.insertTdNtFeedback(tdNtFeedbackInsert);
             retInfo.setMark(ValidationMessages.getValue("MARKYES"));
             retInfo.setTip("添加意见反馈成功");
        } catch (Exception e) {
            retInfo.setMark(ValidationMessages.getValue("MARKERROR"));
            retInfo.setTip(ValidationMessages.getValue("TIPERROR"));
            logger.error(e.getMessage(),e);
        }
        logger.info("======" + logInfo + "end======");
        return retInfo;
    }
}
